package br.com.iqt;

import br.com.iqt.exception.DbmsException;
import br.com.iqt.zql.ZFromItem;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Vector;

/**
 *
 * @author Arlino
 */
public class AgentStatistics {
    private DriverStatistics driver;

    public AgentStatistics(Dbms dbms) throws DbmsException, ClassNotFoundException {
        switch(dbms.getDbms()){
            case Dbms.POSTGRESQL:
                driver = new DriverStatisticsPostgresql(dbms);
                break;
            case Dbms.SQLSERVER:
                driver = new DriverStatisticsSqlserver(dbms);
                break;
            case Dbms.ORACLE:
                driver = new DriverStatisticsOracle(dbms);
                break;
            default:
                throw new DbmsException("SGBD inválido!");
        }
    }
    
    public boolean haveIndex(Vector tables, String column) throws SQLException{
        return driver.haveIndex(tables, column);
    }
    
    public boolean isPrimaryKey(Vector tables, String column) throws SQLException{
        return driver.isPrimaryKey(tables, column);
    }
    
    public ZFromItem getTableWithPrimaryKey(Vector tables, String column) throws SQLException{
        return driver.getTableWithPrimaryKey(tables, column);
    }
    public boolean isForingkeyFromTable1InTabel2(ZFromItem table, String column, Vector from) throws SQLException{
        return driver.isForingkeyFromTable1InTabel2(table, column, from);
    }
    
    public ZFromItem getTableWithForingkeyFromTable1InTabel2(ZFromItem table, String column, Vector from) throws SQLException{
        return driver.getTableWithForingkeyFromTable1InTabel2(table, column, from);
    }
    
    public ArrayList getExecutionPlan(String sql) throws SQLException{
        return driver.getExecutionPlan(sql);
    }
    public String getRealRuntime(String sql) throws SQLException{
        return driver.getRealRuntime(sql);
    }
}
